package com.ruoyi.common.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class CommonStrUtils {
    public CommonStrUtils() {
    }

    public static String handleUrlPath(String url) {
        if (StringUtils.isBlank(url)) {
            return url;
        } else {
            return url.endsWith("/") ? url.substring(0, url.length() - 1) : url;
        }
    }

    public static String urlEncode(String value, String encoding) {
        if (value == null) {
            return "";
        } else {
            try {
                String encoded = URLEncoder.encode(value, encoding);
                return encoded.replace("+", "%20").replace("*", "%2A").replace("~", "%7E").replace("/", "%2F");
            } catch (UnsupportedEncodingException var3) {
                throw new IllegalArgumentException("FailedToEncodeUri", var3);
            }
        }
    }
}
